package com.sponsorpay.sdk.android.utils;

import java.io.IOException;
import java.security.KeyStore;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpProtocolParams;

public class SPHttpClient
{
  private static SPHttpClient INSTANCE = new SPHttpClient();
  private static final String TAG = "SPHttpClient";
  private HttpClient client;

  private HttpClient getClient()
  {
    HttpGet localHttpGet;
    BasicHttpParams localBasicHttpParams;
    SchemeRegistry localSchemeRegistry;
    if (this.client == null)
    {
      localHttpGet = new HttpGet("https://service.sponsorpay.com");
      localBasicHttpParams = new BasicHttpParams();
      HttpProtocolParams.setVersion(localBasicHttpParams, HttpVersion.HTTP_1_1);
      HttpProtocolParams.setContentCharset(localBasicHttpParams, "UTF-8");
      localSchemeRegistry = new SchemeRegistry();
      localSchemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    }
    try
    {
      localSchemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
      this.client = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, localSchemeRegistry), localBasicHttpParams);
      this.client.execute(localHttpGet).getStatusLine();
      return this.client;
    }
    catch (ClientProtocolException localClientProtocolException)
    {
      while (true)
        SponsorPayLogger.e("SPHttpClient", "Client protocol error", localClientProtocolException);
    }
    catch (IOException localIOException)
    {
      while (true)
        try
        {
          KeyStore localKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
          localKeyStore.load(null, null);
          SPSSLSocketFactory localSPSSLSocketFactory = new SPSSLSocketFactory(localKeyStore);
          localSPSSLSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
          localSchemeRegistry.unregister("https");
          localSchemeRegistry.register(new Scheme("https", localSPSSLSocketFactory, 443));
          this.client = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, localSchemeRegistry), localBasicHttpParams);
        }
        catch (Exception localException)
        {
          SponsorPayLogger.e("SPHttpClient", "Unknow error, aborting...", localException);
        }
    }
  }

  public static HttpClient getHttpClient()
  {
    return INSTANCE.getClient();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.utils.SPHttpClient
 * JD-Core Version:    0.6.2
 */